const app = getApp()
//获得全局js变量
var util = require('../../utils/util.js');
Page({
    data: {
        title: '记录',
        loadingType: 0,
        p: 1,
        list: [],
        num: 0,
        userinfo: [],
        isLayer: false
    },
  
    onLoad: function() {
        let title = '余额';
        this.setData({ title });
        wx.setNavigationBarTitle({
            title: title
        });
    },
  
    onShow: function() {
        this.setData({
            userinfo: wx.getStorageSync('user'),
            p: 1,
            list: []
        });
        this.getinfo();
    },
  
    getinfo: function() {
        const that = this;
        util.httpRrquest(app.data.rooturl + 'user/getUserCoin', 'GET',{p:this.data.p})
        .then(function (response) {
            if (response.data.code == 1) {
                if (that.data.p == 1) {
                    that.setData({
                        list: response.data.data,
                        num: response.data.data[0].allnum
                    })
                } else {
                    that.setData({
                        list: that.data.list.concat(response.data.data)
                    })
                }
            }
            that.setData({
                list: response.data.data
            })
        }, function (error) {
            console.log(error);
        });
    },
  
    jumpurl: function(e) {
        const index = e.currentTarget.dataset.index;
        let url = '';
        url = '/pages/mine/withdraw/withdraw';
        wx.navigateTo({
            url: url
        });
    },
  
    onReachBottom: function() {
        this.setData({
            p: this.data.p + 1 
        })
        this.getinfo();
    }
});